package crud.client.authentication;

import crud.client.data.Bonus;
import crud.client.data.Societe;
import crud.client.data.authentication.Authentication;
import crud.client.data.authentication.AuthenticationAdapter;
import crud.client.data.authentication.Right;
import crud.client.data.authentication.User;

public class AuthenticationAdapterImpl implements AuthenticationAdapter
{

	@Override
	public User getUser(String login, String password)
	{
		User user = null;
		if ("admin".equals(login))
		{
			user = new User();
			user.setName(login);
			
			Authentication authentication = new Authentication();
			user.setAuthentication(authentication);
			authentication.setAdmin(true);
		} else if ("eric".equals(login))
		{
			user = new User();
			user.setName(login);
			
			Authentication authentication = new Authentication();
			user.setAuthentication(authentication);
			authentication.setAdmin(true);
			authentication.addRight(Bonus.class.getName(), Right.NONE);
			authentication.addRight(Societe.class.getName(), Right.VISUALISATION);
		}

		return user;
	}

}
